﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace ElingOA6_Admin_DSJCJ.BLL
{
    public partial class SysTemplate
    {
        private readonly ElingOA6_Admin_DSJCJ.DAL.SysTemplate dal = new ElingOA6_Admin_DSJCJ.DAL.SysTemplate();
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<ElingOA6_Admin_DSJCJ.Model.SysTemplate> GetModelList(string strWhere)
        {
            DataSet ds = dal.GetList(strWhere);
            return DataTableToList(ds.Tables[0]);
        }
        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool Delete(decimal FTemplateID)
        {
            return dal.Delete(FTemplateID);
        }

                /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool DeleteList(string idList)
        {
            return dal.DeleteList(idList);
        }

        /// <summary>
        /// 获取文件路径
        /// <creator>rend</creator>
        /// <date>2013-07-18</date>
        /// </summary>
        /// <param name="FTemplateID"></param>
        /// <returns></returns>
        public string GetFileName(decimal FTemplateID)
        {
            return dal.GetFileName(FTemplateID);
        }


        /// <summary>
        /// 获取模板内容
        /// <creator>zhongyl</creator>
        /// <date>2013-07-18</date>
        /// </summary>
        /// <param name="FTemplateID"></param>
        /// <returns></returns>
        public string GetContent(decimal FTemplateID)
        {
            return dal.GetContent(FTemplateID);
        }

        /// <summary>
        /// 增加一条数据
        /// </summary>
        public void Add(ElingOA6_Admin_DSJCJ.Model.SysTemplate model)
        {
             dal.Add(model);
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(ElingOA6_Admin_DSJCJ.Model.SysTemplate model)
        {
             dal.Update(model);
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public ElingOA6_Admin_DSJCJ.Model.SysTemplate GetModel(decimal FTemplateID)
        {
            return dal.GetModel(FTemplateID);
        }
         /// <summary>
        /// 获得非空的文件路径
        /// <creator>wagnl</creator>
        /// <date>2013-08-02</date>
        /// </summary>
        /// <param name="entityNo">公司编号</param>
        /// <param name="sourceNo">对应编码</param>
        /// <returns></returns>
        public List<string> GetFileNames(string entityNo, string sourceNo)
        {
            return dal.GetFileNames(entityNo, sourceNo);
        }
        /// <summary>
        /// 获取模板数据
        /// <creator>wangl</creator>
        /// <date>2013-08-07</date>
        /// </summary>
        /// <param name="entityNo">公司编号</param>
        /// <param name="sourceNo">来源号</param>
        /// <param name="templateType">模板类型</param>
        /// <returns>模板列表</returns>
        public List<Model.SysTemplate> GetListByTemplateType(string entityNo, string sourceNo, string templateType)
        {
            DataSet ds= dal.GetListByTemplateType(entityNo,sourceNo,templateType);
            return DataTableToList(ds.Tables[0]);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<ElingOA6_Admin_DSJCJ.Model.SysTemplate> DataTableToList(DataTable dt)
        {
            List<ElingOA6_Admin_DSJCJ.Model.SysTemplate> modelList = new List<ElingOA6_Admin_DSJCJ.Model.SysTemplate>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                ElingOA6_Admin_DSJCJ.Model.SysTemplate model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = dal.DataRowToModel(dt.Rows[n]);
                    if (model != null)
                    {
                        modelList.Add(model);
                    }
                }
            }
            return modelList;
        }

    }
}
